<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新华保险投票系统v1.0</title>
    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link rel="stylesheet" href="dist/jquery.jqplot.min.css" type="text/css"/>
    <script type="text/javascript" src="dist/jquery.min.js"></script>
    <script type="text/javascript" src="dist/jquery.jqplot.min.js"></script>
    <script type="text/javascript" src="dist/plugins/jqplot.barRenderer.min.js"></script>
    <script type="text/javascript" src="dist/plugins/jqplot.categoryAxisRenderer.min.js"></script>
    <script type="text/javascript" src="dist/plugins/jqplot.pointLabels.min.js"></script>
    <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="dist/excanvas.min.js")"></script><![endif]-->
</head>
<body id="result-vote">
<?php
if(!isset($_COOKIE['islogin']) || $_COOKIE['islogin']!=1){
    echo "<script>window.navigate('login.php');</script>";
}

if(!isset($_GET['action'])){
    echo "<script>window.location.href='login.php';</script>";
}
require('config.php');
$vsID = $_GET['action'];
$result_select=mysql_query("select title from vote_subject where vsID=$vsID") or die(mysql_error());
$row=mysql_fetch_row($result_select);

$select_query_vs = "select description,options from vote_subject where vsID='$vsID'";
$select_query_vi_b = "select image,title,viID,viDES from vote_item where vsID='$vsID' and class='后援'";
$select_query_vi_f = "select image,title,viID,viDES from vote_item where vsID='$vsID' and class='前线'";

$result_query_vs = mysql_query($select_query_vs) or die(mysql_error());
$result_query_vi_b = mysql_query($select_query_vi_b) or die(mysql_error());
$result_query_vi_f = mysql_query($select_query_vi_f) or die(mysql_error());
$row_vs = mysql_fetch_array($result_query_vs);
$description = $row_vs[0];
$account = $_COOKIE['username'];

?>
<div id="nav">
    <div id="nav_top">
        <div class="width navs">
            <div class="logo">
                <a href="index.php" target="ifm"><img src="images/logo.png" width="290" height="54" /></a>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div id="header">
        <div class="width">
        </div>
        </div>
    </div>
</div>
<div id="content">
    <div id="main-content">
        <h3 style="text-align: center;margin-bottom: 30px;">投票结果统计图</h3>
        <input type="hidden" id="result_vsid" value="<?php echo $vsID ?>" />
        <input type="hidden" id="result_title" value="<?php echo $row[0]?>" />
    </div>
</div>
<script type="text/javascript">

    $(function(){
        function getJqplotDate(class_t,chart) {
            var vsid = $("#result_vsid").val();
            var title = $("#result_title").val() + "---"+class_t;
            $.ajax({
                type: 'post',
                dataType: 'json',
                url: 'item-count.php',
                data: {"vsid": vsid,"class_t":class_t},
                success: function (json) {
                    var vcount = new Array();
                    var ticks = new Array();
                    vcount = json.count;
                    ticks = json.name;

                    var plot2 = $.jqplot(chart, [vcount], {
                        title: title,

                        seriesDefaults: {
                            renderer: $.jqplot.BarRenderer,
                            // Show point labels to the right ('e'ast) of each bar.
                            // edgeTolerance of -15 allows labels flow outside the grid
                            // up to 15 pixels.  If they flow out more than that, they
                             // will be hidden.
                            pointLabels: {show: true, location: 'e', edgeTolerance: -15},
                            // Rotate the bar shadow as if bar is lit from top right.
                            shadowAngle: 135,
                            // Here's where we tell the chart it is oriented horizontally.
                            rendererOptions: {
                                barDirection: 'horizontal',
                                varyBarColor: true
                            }
                        },

                        axes: {
                            xaxis: {
                                max: 150
                            },
                            yaxis: {
                                renderer: $.jqplot.CategoryAxisRenderer,
                                ticks: ticks
                            }

                        }
                    });
                }
            });
        }
        getJqplotDate("后援","chart_b");
        getJqplotDate('前线',"chart_f");
    });

</script>
<div id="view-vote" style="width: 941px;margin: 0 auto;">
    <div style="overflow: hidden;border:1px solid gray;">
        <h3 style="background-color:#22C3AA;color: white;padding: 5px 5px 5px 20px;">月度明星评选--后援伙伴</h3>
        <div id="chart_b" style="margin-top: 20px;width: 800px;height: 300px;"></div>

        <?php
        while($row_vi=mysql_fetch_array($result_query_vi_b)){
            $path = "files/".$row_vi['image'];
            ?>
            <div class="vote_box">
                <img src="<?php echo $path; ?>" alt="选项图片"/>
                <p><?php echo $row_vi['title'];?></p>
                <div class="follow">
                    <p><input type="checkbox" name="vote_me" value="<?php echo $row_vi['viID'];?>" class="vote_me_b"/>
                        选我----><a class="show_me" target="_blank" href="show-des.php?action=<?php echo $row_vi['viID'];?>">详情</a></p>
                </div>
            </div>
        <?php } ?>
    </div>

    <div style="overflow:hidden; border:1px solid gray;">
        <h3 style="background-color:#22C3AA;color: white;padding: 5px 5px 5px 20px;">月度明星评选--前线伙伴</h3>
        <div id="chart_f" style="margin-top: 20px;width: 800px;height: 300px;"></div>

        <?php
        while($row_vi=mysql_fetch_array($result_query_vi_f)){
            $path = "files/".$row_vi['image'];
            ?>
            <div class="vote_box">
                <img src="<?php echo $path; ?>" alt="选项图片"/>
                <p><?php echo $row_vi['title'];?></p>
                <div class="follow">
                    <p><input type="checkbox" name="vote_me" value="<?php echo $row_vi['viID'];?>" class="vote_me_f"/>
                        选我----><a class="show_me" target="_blank" href="show-des.php?action=<?php echo $row_vi['viID'];?>">详情</a></p>
                </div>
            </div>
        <?php } ?>
    </div>

</div>
</body>
</html>
